package com.cluster.gulimall.order.app;


import com.cluster.gulimall.common.utils.PageUtils;
import com.cluster.gulimall.common.utils.R;
import com.cluster.gulimall.order.entity.OmsOrderItem;
import com.cluster.gulimall.order.service.IOmsOrderItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;

/**
 * <p>
 * 订单项信息 前端控制器
 * </p>
 *
 * @author dqh
 * @since 2024-08-20
 */
@RestController
@RequestMapping("order/orderitem")
public class OmsOrderItemController {


    @Autowired
    private IOmsOrderItemService orderItemService;


    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("order:orderitem:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = orderItemService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("order:orderitem:info")
    public R info(@PathVariable("id") Long id){
        OmsOrderItem orderItem  = orderItemService.getById(id);
        return R.ok().put("orderItem", orderItem);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("order:orderitem:save")
    public R save(@RequestBody OmsOrderItem orderItem){
        orderItemService.save(orderItem);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("order:orderitem:update")
    public R update(@RequestBody OmsOrderItem orderItem){
        orderItemService.updateById(orderItem);
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("order:orderitem:delete")
    public R delete(@RequestBody Long[] ids){
        orderItemService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

}
